<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="/pages/login/common.jsp" %>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description"/>
<meta content="B2B电商平台" name="keyword"/>

<title>B2B电商平台.店铺</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/demo.css">
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/register_icss.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/sweetalert/sweetalert.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
<link rel="stylesheet" href="<%=path %>/include/JQuery ui/select2/css/select2.min.css" type="text/css"></link>

<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.shop.apply.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>

<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.core-3.4.js"></script>
<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.excheck-3.4.js"></script>

<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>
<script type="text/javascript" src="<%=path %>/include/JQuery ui/select2/js/select2.min.js"></script>

	<link rel="stylesheet" href="<%=path%>/include/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="<%=path %>/include/layui/lay/dest/layui.all.js" charset="utf-8"></script>
	
<style type="text/css">
body{}
table{border-collapse: collapse;}
tr{ 
    display:block; /*将tr设置为块体元素*/ 
    margin:10px;  /*设置tr间距为2px*/ 
}
td{height:30px; line-height:30px;}
.td1{
	width:100px;
	font-size:14px;
	text-align:right;
	vertical-align: middle;
}
#btnDiv a:hover{
   color:white;
}
button{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}
.input1{
	width:200px;
	height:30px;
	line-height:30px;
	vertical-align:middle;
	float:left;
}
.select1{
	width: 196px;
    height: 30px;
}
.select2{
    height: 30px;
}
.acss:hover{
	background: #fff;
}
.promptBox{display:inline-block;height:30px;padding-left:5px;width:160px;white-space:nowrap; z-index:50; position:relative;}
.tips-errow{background-position:-296px -22px;color:#f52c2c;}
.tips-ok{background-position:-296px 14px;color:#666;}
.tipsCur{background-position:-296px -55px;color:#666;}
.approveDiv{float:right;color:blue;margin-right:10px;}
</style>
<script type="text/javascript">
	var registerStatus = '${shopInfo.REGISTER_STATUS}';
//	var registerStatus = '1';
	$(function(){
		/*if(registerStatus== null || registerStatus == ''){
			$("#approveDiv").hide();
		}else if(registerStatus == 0){
			//$("#approveDiv").html("审核状态：待审核");
			//$("#btnDiv").hide();
			//$('input,select,textarea',$('form[name="fm"]')).prop('readonly',true); 
		}else if(registerStatus == 1){
			//$("#approveDiv").html("审核状态：审核通过");
			$("#btnDiv").hide();
			$('input,select,textarea',$('form[name="fm"]')).prop('readonly',true); 
		}else if(registerStatus == 2){
			//$("#approveDiv").html("审核状态：审核不通过");
		}*/
	});
	
	function saveShop(val){
		if(val!='2') $("#status").val("");
		if(_checkAllReady()){
			$.ajax({
	              cache: true,
	              type: "POST",
	              url:'<%=path%>/storeApplyAction/saveOne.do',
	              data:$('#fm').serialize(),
	              dataType:"json",
	              error: function(request) {
	                 parent.swal("", "提交失败!", "error");
	              },
	              success: function(data) {
	                var msg = data.result;
	                if(msg=="保存成功"){
						//parent.swal("", msg, "success");
						var showFlag = $("#showFlag").val();
						if(showFlag=="1")
							window.location.href = '<%=path %>/storeApplyAction/toStoreInfo.do?shopId='+data.shopId;
						else
	                    	window.location.href = '<%=path %>/storeApplyAction/toStoreApplyTwoPage.do?shopId='+data.shopId;
					}else {
						parent.swal("", msg, "error");
					}
	              }
	         });
		}
	}

	function _changePro(val,id,level){
		if(val==""){
			$("#"+id).empty();
			$("#"+id).hide();
			$("#shopCounty").empty();
			$("#shopCounty").hide();
			return;
		}
		$.ajax({
              cache: true,
              type: "POST",
              url:'<%=path%>/storeApplyAction/queryProvinceCityList.do',
              data:{areaPcode : val,level:level},
              async: false,
              dataType : 'json',
              error: function(request) {
              },
              success: function(data) {
              	 if(data){
              	 	var list = data;
              	 	if(list.length>0){
						$("#"+id).empty();
						$("#shopCounty").empty();
						$("#shopCounty").hide();
						var obj = "";
						for(var i =0 ;i<list.length;i++){
							var info = list[i];
							var AREA_NAME = info.AREA_NAME;
							var AREA_CODE = info.AREA_CODE;
							$("#"+id).append("<option value='"+AREA_CODE+"'>"+AREA_NAME+"</option>");
							if(i==0) obj=AREA_CODE;
						}
						$("#"+id).show();
						if(level=="3"){
							 _changePro(obj,"shopCounty","4");
						}
					}
              	 }
              }
        });
	}
	
</script>
</head>
<body style="font-family: '微软雅黑'">
	<div id="contentDiv" style="padding:5px; width:99%;margin: 0px;">
		<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;">
			<div class="toptil">开店申请-基础信息</div>
	 		<div id="approveDiv" class="approveDiv">
	 		</div>
		</div>
		<form id="fm" name="fm" class="form-horizontal form-validate" method="post" action="" novalidate="novalidate">
			<input type="hidden" id="registerStatus" name="registerStatus" value="${shopInfo.REGISTER_STATUS}">
			<input type="hidden" id="shopId" name="shopId" value="${shopInfo.SHOP_ID }">
			<input type="hidden" id="curPath" name="curPath" value="<%=path %>">
			<input type="hidden" id="showFlag" name="showFlag" value="${showFlag }">
			<input type="hidden" id="shopStatus" name="shopStatus" value="${shopInfo.SHOP_STATUS }">
			<input type="hidden" id="status" name="status" value="${shopInfo.STATUS }">
			<div style="width:100%;margin-top:20px;margin-left:10px;">
				<table style="width:100%;">
					<tr>
						<td class="td1" nowrap>店铺名称：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="shopName" name="shopName" value="${shopInfo.SHOP_NAME }">
							<div class="promptBox">
	                       		<div class='tips-errow' style="display:none;">店铺名称已存在</div>
	                       		<div class='tips-ok' style="display:none;"></div>
	                       		<div class='tipsCur' style="display:none;">请输入店铺名称</div>
	                       	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>法人姓名：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="legalPerson" name="legalPerson" value="${shopInfo.LEGAL_PERSON }">
							<div class="promptBox">
	                       		<div class='tips-errow' style="display:none;">法人姓名已存在</div>
	                       		<div class='tips-ok' style="display:none;"></div>
	                       		<div class='tipsCur' style="display:none;">请输入法人姓名</div>
	                       	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" style="vertical-align:top;white-space: nowrap;">店铺地址：</td>
						<td class="rightTd">
							<select class="select2" id="shopProvince" name="shopProvince" onchange="_changePro(this.value,'shopCity','3')">
								<option value=""  >---请选择---</option>
								<c:forEach items="${provinceList}" var="province" > 
									<option value="${province.AREA_CODE }" <c:if test="${province.AREA_CODE eq shopInfo.SHOP_PROVINCE}">selected="selected"</c:if>>${province.AREA_NAME }</option>
								</c:forEach>
							</select>
							<select class="select2" id="shopCity" name="shopCity" <c:if test="${fn:length(cityList) eq 0}">style="display:none;"</c:if> onchange="_changePro(this.value,'shopCounty','4')">
								<c:forEach items="${cityList}" var="city" > 
									<option value="${city.AREA_CODE }" <c:if test="${city.AREA_CODE eq shopInfo.SHOP_CITY}">selected="selected"</c:if>>${city.AREA_NAME }</option>
								</c:forEach>
							</select>
							<select class="select2" id="shopCounty" name="shopCounty" <c:if test="${fn:length(countyList) eq 0}">style="display:none;"</c:if>>
								<c:forEach items="${countyList}" var="county" > 
									<option value="${county.AREA_CODE }" <c:if test="${county.AREA_CODE eq shopInfo.SHOP_COUNTY}">selected="selected"</c:if>>${county.AREA_NAME }</option>
								</c:forEach>
							</select>
						</td>
					</tr>
					<tr>
						<td class="td1" style="vertical-align:top;white-space: nowrap;">详细地址：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="shopAddr" name="shopAddr" value="${shopInfo.SHOP_ADDRESS }">
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入详细地址</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入详细地址</div>
		                   	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>店铺电话：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="shopTel" name="shopTel" value="${shopInfo.SHOP_TEL }">
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入店铺电话</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入店铺电话</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">店铺图片：</td>
						<td class="rightTd" nowrap style="vertical-align:top;">
							<div id="shopLogoDiv" style="float:left;margin-right:10px;text-align:center;">
								<div id="imgDiv3" style="margin-bottom:10px;">
									<img src="${shopInfo.SHOP_LOGO }" onerror="javascript:this.src='<%=path%>/download/error/nopicture.jpg'"
										id="imgView3" style="height: 75px; width: 100px;">
								</div>
								<div id="file1" class="site-demo-upbar" style="">
								    <input type="file" name="file" class="layui-upload-file" id="img3">
								</div>
								<input id="shopLogo" name="shopLogo" type="hidden" value="${shopInfo.SHOP_LOGO }">
							</div>
							<div id="shopPicDiv" style="float:left;text-align:center;">
								<div id="imgDiv4" style="margin-bottom:10px;">
									<img src="${shopInfo.SHOP_PIC }" onerror="javascript:this.src='<%=path%>/download/error/nopicture.jpg'"
										id="imgView4" style="height: 75px; width: 100px;">
								</div>
								<div id="file1" class="site-demo-upbar" style="">
								    <input type="file" name="file" class="layui-upload-file" id="img4">
								</div>
								<input id="shopPic" name="shopPic" type="hidden" value="${shopInfo.SHOP_PIC }">
							</div>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请上传店铺图片</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请上传店铺图片</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;width:100px;">店铺详情：</td>
						<td class="rightTd" nowrap>
							<textarea id="shopDesc" name="shopDesc" style="width: 400px; height: 80px; resize: none;">${shopInfo.SHOP_DESC }</textarea>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入店铺详情</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入店铺详情</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">身份证：</td>
						<td class="rightTd" id="td1" nowrap>
							<div id="idcardDiv" style=";float:left;margin-right:10px;text-align:center;">
								<div id="imgDiv1" style="margin-bottom:10px;">
									<img src="${shopInfo.IDCARD_NO_PIC_F }" onerror="javascript:this.src='<%=path%>/download/error/nopicture.jpg'"
										id="imgView1" style="height: 75px; width: 100px;">
								</div>
								<div id="file1" class="site-demo-upbar" style="">
								    <input type="file" name="file" class="layui-upload-file" id="img1">
								</div>
								<input id="idcardF" name="idcardF" type="hidden" value="${shopInfo.IDCARD_NO_PIC_F }">
							</div>
							<div style="float:left;text-align:center;">
								<div id="imgDiv2" style="margin-bottom:10px;">
									<img src="${shopInfo.IDCARD_NO_PIC_B }" onerror="javascript:this.src='<%=path%>/download/error/nopicture.jpg'"
										id="imgView2" style="height: 75px; width: 100px;">
								</div>
								<div id="file1" class="site-demo-upbar" style="">
								    <input type="file" name="file" class="layui-upload-file" id="img2">
								</div>
								<input id="idcardB" name="idcardB" type="hidden" value="${shopInfo.IDCARD_NO_PIC_B }">
							</div>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请上传身份证正/反面照片</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请上传身份证正/反面照片</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1">&nbsp;</td>
						<td style="">
							<div id="btnDiv" <c:if test="${showFlag eq '1'}">style="display: none;"</c:if>>
								<a onclick="saveShop('0');" class="btn btn-primary" style="text-decoration:none;">下一步</a>
							</div>
							<c:if test="${showFlag eq '1'}">
								<div id="btnDiv" style="float: left;">
									<a onclick="saveShop('1');" class="btn btn-primary" style="text-decoration:none;">保存</a>
								</div>
								<c:if test="${shopInfo.STATUS eq '2'}">
									<div id="btnDiv" style="float: left;margin-left: 15px;">
										<a onclick="saveShop('2');" class="btn btn-primary" style="text-decoration:none;">提交</a>
									</div>
								</c:if>
							</c:if>
						</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
</body>
<script type="text/javascript">
layui.use('upload', function(){
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img1' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'正面照'
	    ,success: function(res){
			$("#idcardF").val(res.url);
			$("#imgView1").attr("src", res.url);
			if($.trim($("#idcardF").val()) != '' && $.trim($("#idcardB").val()) != ''){
				$("#idcardDiv").nextAll('div').find(".tips-errow").hide();
				$("#idcardDiv").nextAll('div').find(".tipsCur").hide();
				$("#idcardDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img2' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'反面照'
	    ,success: function(res){
			$("#idcardB").val(res.url);
			$("#imgView2").attr("src", res.url);
			$("#idcardB").parent().nextAll().find(".tips-ok").hide();
			$("#idcardB").parent().nextAll().find(".tips-errow").hide();
			$("#idcardB").parent().nextAll().find(".tipsCur").show();
			if($.trim($("#idcardF").val()) != '' && $.trim($("#idcardB").val()) != ''){
					$("#idcardDiv").nextAll('div').find(".tips-errow").hide();
				$("#idcardDiv").nextAll('div').find(".tipsCur").hide();
				$("#idcardDiv").nextAll('div').find(".tips-ok").show();
				}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img3' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'店铺logo'
	    ,success: function(res){
		 	$("#shopLogo").val(res.url);
			$("#imgView3").attr("src", res.url); 
			if($.trim($("#shopLogo").val()) != ''){
				$("#shopLogoDiv").nextAll('div').find(".tips-errow").hide();
				$("#shopLogoDiv").nextAll('div').find(".tipsCur").hide();
				$("#shopLogoDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img4' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'宣传图片'
	    ,success: function(res){
	       	$("#shopPic").val(res.url);
			$("#imgView4").attr("src", res.url);
			if($.trim($("#shopPic").val()) != ''){
				$("#shopPicDiv").nextAll('div').find(".tips-errow").hide();
				$("#shopPicDiv").nextAll('div').find(".tipsCur").hide();
				$("#shopPicDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img5' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'上传'
	    ,success: function(res){
		 	$("#businessLicense").val(res.url);
			$("#imgView5").attr("src", res.url);
			if($.trim($("#businessLicense").val()) != ''){
				$("#businessLicenseDiv").nextAll('div').find(".tips-errow").hide();
				$("#businessLicenseDiv").nextAll('div').find(".tipsCur").hide();
				$("#businessLicenseDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
});
</script>
<script type="text/javascript">
	$(document).ready(function(){
		_reHeight();
	});
	function _reHeight(){
		var main = $(window.parent.document).find("#rightFrame");
		var mainheight = $("#contentDiv").height();
		main.height(mainheight);
	}
</script>
</html>
